<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // var ldh = {
    //   age: 18,
    //   address: 'ifsaf',
    //   username: '刘德华'
    // }
    // var zxy = {
    //   age: 28,
    //   address: 'wqeqwe',
    //   username: '张学友'
    // }

    // 工厂 构造函数
    function Student(username, age) {
      this.username = username
      this.age = age
      this.fn = function(info) {
        console.log(info)
      }
    }

    //构造函数创建的对象： 实例
    var ldh = new Student('刘德华', 18)

    console.log(ldh)
    ldh.fn('你真好')

    var zxy = new Student('张学友', 28)
    console.log(zxy)
    zxy.fn('你好坏')



    // 1. 首字母大写
    // 2. this
    // 3. 调用函数 前边一定要有 new
  </script>
</body>
</html>